﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PICCommands.Commands;

namespace PICCommands.IO
{
    public class DigitalOutChannel:IToggleable
    {
        private readonly IExecutable _onCommand;
        private readonly IExecutable _offCommand;

        public bool IsOn{get; private set;}
        public string Id { get; private set; }

        public DigitalOutChannel(string id, IExecutable onCommand, IExecutable offCommand)
        {
            Id = id;
            _onCommand = onCommand;
            _offCommand = offCommand;
        }

        public void On()
        {
            _onCommand.Execute();
            IsOn = true;
        }

        public void Off()
        {
            _offCommand.Execute();
            IsOn = false;
        }
    }
}
